package com.leetcode;

/**
 * 944. 删列造序
 * 直接遍历
 *
 * @author fy
 * @date 2022/5/12 22:09
 */
public class Solution944 {

    public int minDeletionSize(String[] strs) {
        int n = strs.length;
        int m = strs[0].length();

        int res = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 1; j < n; j++) {
                if (strs[j - 1].charAt(i) > strs[j].charAt(i)) {
                    res++;
                    break;
                }
            }
        }
        return res;
    }


    public static void main(String[] args) {
        String[] strs = new String[]{"cba", "daf", "ghi"};
        int res = new Solution944().minDeletionSize(strs);
        System.out.println(res);
    }

}
